<%@page import="HomespDTO.HomespDTO_category"%>
<%@page import="HomespDAO.HomespDAO_goods"%>
<%request.setCharacterEncoding("euc-kr");%>
<%response.setContentType("text/html; charset=euc-kr");%>
<%@ page contentType="text/html; charset=euc-kr"%>
<%@page import="HomespDTO.HomespDTO_goods"%>
<%@page import="java.util.ArrayList"%>
<html>
	<head>
		<title> 메인 </title>
	</head>
	<body>
	<BODY TopMargin="0" LeftMargin="0">
		<%
			Object o = request.getAttribute("CAlist");
			ArrayList<HomespDTO_goods> CAlist = (ArrayList)o;
			HomespDAO_goods dao = new HomespDAO_goods();
	    	ArrayList<HomespDTO_goods> list =  dao.getAllUsers();
		%>
		<TABLE Width="580" Border="0" CellPadding="3" CellSpacing="5" align="center">
		<%
	    	if(o==null || o.equals("")) {
	    		int n=0;
	    		for(int i=0;i<list.size();i++) {
					HomespDTO_goods dto = list.get(i);
					if(i%3==0) {
						n++;
		%>
					<tr>
		<%
					}
		%>
		   <TD>
		      <TABLE Width="200" Align="center" Border="0">
			  <TR>
				 <TD Align="center">
				      <A HRef='Control.jsp?command=GoodsList&gid=<%=dto.getGid()%>' Target="right"><IMG Src='image/<%=dto.getImg()%>' Width="200" Border="0" Height="300"></A>
			     </TD>
		      </TR> 		  
			  <TR>
			     <TD Align="center" BGColor="#000000" ColSpan="2"><font color="#ffffff" face="돋움"><%=dto.getGname()%></font></TD>		 
		      </TR>
		      <TR>		
				 <TD align="center"><b><h5><%=dto.getPrice()%></h5></b></TD>
		      </TR> 
			  </TABLE>
		   </TD>
		<%
				} for(int j=0;j<n;j++) {
		%>
					</tr>
		<%
				}
	    	} else {
	    		int n=0;
				for(int i=0;i<CAlist.size();i++) {
					HomespDTO_goods dto = CAlist.get(i);
					if(i%3==0) {
						n++;
		%>
					<tr>
		<%
					}
		%>
			  <TD>
		      <TABLE Width="200" Align="center" Border="0">
			  <TR>
				 <TD Align="center">
				      <A HRef='Control.jsp?command=GoodsList&gid=<%=dto.getGid()%>' Target="right"><IMG Src='image/<%=dto.getImg()%>' Width="200" Border="0" Height="300"></A>
					  </TD>
		      </TR> 	
		      <TR>
			     <TD Align="center" BGColor="#000000" ColSpan="2"><font color="#ffffff" face="돋움"><%=dto.getGname()%></font></TD>		 
		      </TR>	  
		      <TR>		
				 <TD align="center"><b><h5><%=dto.getPrice()%></h5></b></TD>
		      </TR> 
			  </TABLE>
		   </TD>
		<%
				}for(int j=0;j<n;j++) {
		%>
					</tr>
		<%
				}	
	    	}
		%>
		</TABLE>
	</body>
</html>